package com.mlethe.android.demo.seattable.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import androidx.annotation.NonNull;

import com.mlethe.android.demo.R;
import com.mlethe.android.demo.seattable.activity.MovieSessionActivity;
import com.mlethe.android.demo.seattable.entity.MovieInfo;
import com.mlethe.library.recyclerview.adapter.BaseQuickAdapter;
import com.mlethe.library.recyclerview.viewholder.ViewHolder;
import com.mlethe.library.utils.DateUtil;

public class MovieAdapter extends BaseQuickAdapter<MovieInfo> {
    public MovieAdapter() {
        super(R.layout.item_movie);
    }

    @Override
    protected void convert(@NonNull ViewHolder holder, MovieInfo item, int position) {
        holder.setText(R.id.item_movie_name_tv, item.getMovieName())
                .setText(R.id.item_movie_starring_tv, "")
                .setText(R.id.item_movie_language_tv, item.getMovieLanguage())
                .setText(R.id.item_movie_length_tv, (item.getTime() / DateUtil.MINUTE) + "分钟")
                .setOnClickListener(R.id.item_movie_buy_btn, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Context context = getContext();
                        Intent intent = new Intent(context, MovieSessionActivity.class);
                        intent.putExtra("playIds", item.getHallIds());
                        context.startActivity(intent);
                    }
                });
    }
}
